package com.chinanet.netelementmodel;


import com.chinanet.entry.netelement.Attr;
import com.chinanet.entry.netelement.AttrType;
import com.chinanet.entry.netelement.WorkInterFace;
import com.chinanet.utils.telnet.ITelnet;
import com.chinanet.utils.telnet.Socket2Telnet;

import java.net.Socket;
import java.util.HashMap;
import java.util.Map;
/**
 * ZX_Mmtel_Query_UBBI_Imp
 * 中兴IMS-mmtel网元-查询用户基本业务信息
 *
 * @author zyd
 * SHOW OSU SBR:PUI="tel:+8657688910054";
 */
public class ZX_Mmtel_Query_UBBI_Imp implements WorkInterFace {

    @Override
    public String getName() {
        return "查询用户基本业务信息";
    }

    @Override
    public String getDesciption() {
        return "";
    }

    @Override
    public int getVersion() {
        return 0;
    }

    @Override
    public Attr[] getInAttrs() {
        Attr[] in = new Attr[1];
        in[0] = new Attr("command", "查询指令", AttrType.TYPE_String, true);
        return in;
    }

    @Override
    public Attr[] getOutAttrs() {
        Attr[] out = new Attr[61];
        out[0] = new Attr("PUI", "PUI", AttrType.TYPE_String, true);
        out[1] = new Attr("网络类型", "网络类型", AttrType.TYPE_String, true);
        out[2] = new Attr("国家码", "国家码", AttrType.TYPE_String, true);
        out[3] = new Attr("区号", "区号", AttrType.TYPE_String, true);
        out[4] = new Attr("用户类型", "用户类型", AttrType.TYPE_String, true);
        out[5] = new Attr("在线计费标识", "在线计费标识", AttrType.TYPE_String, true);
        out[6] = new Attr("离线计费标识", "离线计费标识", AttrType.TYPE_String, true);
        out[7] = new Attr("未开通标识", "未开通标识", AttrType.TYPE_String, true);
        out[8] = new Attr("欠费标识", "欠费标识", AttrType.TYPE_String, true);
        out[9] = new Attr("提醒已呼转标识", "提醒已呼转标识", AttrType.TYPE_String, true);
        out[10] = new Attr("提醒呼转激活标识", "提醒呼转激活标识", AttrType.TYPE_String, true);
        out[11] = new Attr("呼出停机标识", "呼出停机标识", AttrType.TYPE_String, true);
        out[12] = new Attr("呼入停机标识", "呼入停机标识", AttrType.TYPE_String, true);
        out[13] = new Attr("卡类用户业务标识", "卡类用户业务标识", AttrType.TYPE_String, true);
        out[14] = new Attr("强制在线业务标识", "强制在线业务标识", AttrType.TYPE_String, true);
        out[15] = new Attr("支持重叠发号标识", "支持重叠发号标识", AttrType.TYPE_String, true);
        out[16] = new Attr("前转禁止转长途标识", "前转禁止转长途标识", AttrType.TYPE_String, true);
        out[17] = new Attr("呼出权限", "呼出权限", AttrType.TYPE_String, true);
        out[18] = new Attr("呼入权限", "呼入权限", AttrType.TYPE_String, true);
        out[19] = new Attr("欠费呼出权限", "欠费呼出权限", AttrType.TYPE_String, true);
        out[20] = new Attr("欠费呼入权限", "欠费呼入权限", AttrType.TYPE_String, true);
        out[21] = new Attr("群呼出权限", "群呼出权限", AttrType.TYPE_String, true);
        out[22] = new Attr("群呼入权限", "群呼入权限", AttrType.TYPE_String, true);
        out[23] = new Attr("媒体能力", "媒体能力", AttrType.TYPE_String, true);
        out[24] = new Attr("位置区号码", "位置区号码", AttrType.TYPE_String, true);
        out[25] = new Attr("国际移动用户标识", "国际移动用户标识", AttrType.TYPE_String, true);
        out[26] = new Attr("行政区号", "行政区号", AttrType.TYPE_String, true);
        out[27] = new Attr("公司编号", "公司编号", AttrType.TYPE_String, true);
        out[28] = new Attr("客户类型", "客户类型", AttrType.TYPE_String, true);
        out[29] = new Attr("语言类型", "语言类型", AttrType.TYPE_String, true);
        out[30] = new Attr("账单索引", "账单索引", AttrType.TYPE_String, true);
        out[31] = new Attr("特定用户", "特定用户", AttrType.TYPE_String, true);
        out[32] = new Attr("主叫分析选择子", "主叫分析选择子", AttrType.TYPE_String, true);
        out[33] = new Attr("被叫分析选择子", "被叫分析选择子", AttrType.TYPE_String, true);
        out[34] = new Attr("进行位置更新", "进行位置更新", AttrType.TYPE_String, true);
        out[35] = new Attr("用户类属", "用户类属", AttrType.TYPE_String, true);
        out[36] = new Attr("用户计费类型", "用户计费类型", AttrType.TYPE_String, true);
        out[37] = new Attr("用户预付费标志", "用户预付费标志", AttrType.TYPE_String, true);
        out[38] = new Attr("重路由计费提醒标志", "重路由计费提醒标志", AttrType.TYPE_String, true);
        out[39] = new Attr("主叫类型", "主叫类型", AttrType.TYPE_String, true);
        out[40] = new Attr("未注册前转禁止转长途", "未注册前转禁止转长途", AttrType.TYPE_String, true);
        out[41] = new Attr("前转禁止转本地长途", "前转禁止转本地长途", AttrType.TYPE_String, true);
        out[42] = new Attr("前转禁止转国内长途", "前转禁止转国内长途", AttrType.TYPE_String, true);
        out[43] = new Attr("前转禁止转国际长途", "前转禁止转国际长途", AttrType.TYPE_String, true);
        out[44] = new Attr("前转禁止转国港澳台长途", "前转禁止转国港澳台长途", AttrType.TYPE_String, true);
        out[45] = new Attr("用户预付费类型", "用户预付费类型", AttrType.TYPE_String, true);
        out[46] = new Attr("用户最大呼叫路数", "用户最大呼叫路数", AttrType.TYPE_String, true);
        out[47] = new Attr("媒体能力模板号", "媒体能力模板号", AttrType.TYPE_String, true);
        out[48] = new Attr("企业标识", "企业标识", AttrType.TYPE_String, true);
        out[49] = new Attr("被叫流程支持在线计费", "被叫流程支持在线计费", AttrType.TYPE_String, true);
        out[50] = new Attr("位置区索引", "位置区索引", AttrType.TYPE_String, true);
        out[51] = new Attr("PBX群标识", "PBX群标识", AttrType.TYPE_String, true);
        out[52] = new Attr("IMS用户类型", "IMS用户类型", AttrType.TYPE_String, true);
        out[53] = new Attr("呼叫加黑", "呼叫加黑", AttrType.TYPE_String, true);
        out[54] = new Attr("省号标识", "省号标识", AttrType.TYPE_String, true);
        out[55] = new Attr("CS域重路由", "CS域重路由", AttrType.TYPE_String, true);
        out[56] = new Attr("一号多卡用户属性", "一号多卡用户属性", AttrType.TYPE_String, true);
        out[57] = new Attr("无应答呼叫时长(秒)", "无应答呼叫时长(秒)", AttrType.TYPE_String, true);
        out[58] = new Attr("呼叫它网用户", "呼叫它网用户", AttrType.TYPE_String, true);
        out[59] = new Attr("呼叫它网用户提示音", "呼叫它网用户提示音", AttrType.TYPE_String, true);
        out[60] = new Attr("log", "日志文件", AttrType.TYPE_String, true);
        return out;
    }

    @Override
    public Map<String, Object> init(Map<String, Object> data) {
        String param = ITelnet.getInputPhoneFormat(data.get("command").toString());
        Socket2Telnet s = new Socket2Telnet(new Socket(), "134.96.213.68", 21123);
        s.getIns().add("tz.skb");
        s.getIns().add("tz.skb111");
        s.getIns().add("SET AMO:NAME=\"HZMMTEL202-SSS_141\"");
        s.getIns().add("get");
        s.getIns().add("SHOW OSU SBR:PUI=\""+param+"\"");
        s.setProp("$HZMMTEL202-SSS_141>");
        s.run();
        if (s.getResult() != null) {
            System.out.println("成功获取数据");
        } else {
            System.out.println("发生错误");
        }
        Map<String, Object> outmap;
        String pattern = "\\S+|=|\\S*\\n";
        // 将结果进行格式化
        String result = s.getResult().toString().replaceAll("( )+","|=|");
        outmap = ITelnet.matching(pattern, result);
        outmap.put("log",s.getResult().toString());
        return outmap;
    }
}
